export const state ={
  chatList:[
    {
      title: '默认问答',
      content:'你好，欢迎使用南邮智能客服~',
      time:'15:06',
      id: 1,
      type:'smartRobot',
      history:[]
    },
  ],
  activeChatId:1
}
const getter = () => {}

export const mutations ={
  ADD_CHAT: (state, message) => {
    state.chatList.splice(1, 0, message)
  },
  DELETE_CHAT: (state, message) => {
    state.chatList = state.chatList.filter(item=>item.id!==message.id)
  },
  CHANGE_CHATID: (state, activeChatId) => {
    state.activeChatId = activeChatId
  },
}

export const actions = {
  nuxtServerInit({ commit }, { req, app }) {

  },
  // 使用 actions 来访问 $cookies
  setAddChat({ commit }, message) {
    commit('ADD_CHAT', message)
  },
  setDeleteChat({ commit },message) {
    commit('DELETE_CHAT', message)
  },
  changeActiveChatId({ commit }, activeChatId) {
    commit('CHANGE_CHATID', activeChatId)
  }

};
